package com.zmm.member.service.impl;

import com.zmm.member.dao.MemberDao;
import com.zmm.member.model.Member;
import com.zmm.member.service.MemberService;
import com.zmm.member.vo.MemberVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description:
 * @Name MemberServiceImpl
 * @Author Zebulon
 * @Date By 2021-06-21 21:54:04
 */
@Service
public class MemberServiceImpl implements MemberService {

    @Resource
    private MemberDao memberDao;

    /**
    @Autowired
    public void setMemberMapper(MemberDao memberMapper){
        this.memberMapper = memberMapper;
    }
     */

    @Override
    public List<Member> findMemberInfo() {
        return memberDao.findMemberInfo();
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean addMember(Member member) {
        Integer insert = memberDao.insertMember(member);
        if (insert > 0) {
            return true;
        }
        return false;
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean modifyMember(Member member) {
        Integer update = memberDao.updateMember(member);
        if (update > 0) {
            return true;
        }
        return false;
    }

    @Override
    public Member findOneMemberById(Integer id) {
        return memberDao.findMemberById(id);
    }

    @Override
    public List<Member> queryMemberByVo(MemberVo memberVo) {
        return memberDao.queryMemberByVo(memberVo);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void deleteMemberById(Integer id) {
        memberDao.deleteMemberById(id);
    }
}
